DEFINITION MODULE Screen;

   (* This module defines types and procedures associated with *)
   (* the physical screen.                                     *)


   TYPE Pixel = INTEGER;

   TYPE PixelCoordinate = RECORD
      X : Pixel;
      Y : Pixel
   END;

   TYPE Area = RECORD
      Width  : Pixel;
      Height : Pixel
   END;

   TYPE Box = RECORD
      Origin : PixelCoordinate;
      Size   : Area
   END;

   TYPE BoxCorners = RECORD
      UpperLeft  : PixelCoordinate;
      LowerRight : PixelCoordinate
   END;

   TYPE PossibleResolutions = ( LowRes, MediumRes, HighRes );

   TYPE ColorIndex = ( White,     Black,     Red,         Green,
                       Blue,      Cyan,      Yellow,      Magenta,
                       White2,    Black2,    LightRed,    LightGreen,
                       LightBlue, LightCyan, LightYellow, LightMagenta );

   TYPE ClipStatus = ( ClippingOff, ClippingOn );


   VAR PhysicalHandle : INTEGER;

      (* Screen device driver handle (id) *)

   VAR VirtualHandle : INTEGER;         

      (* Screen virtual workstation handle (id) *)

   VAR Resolution : PossibleResolutions;

      (* Indicates the type of monitor connected to the system. *)

   VAR WorkSpace : Box;

      (* Size of the available work space (screen area less menu bar). *)

   VAR CharacterArea : Area;

      (* Size of a single character cell. *)

   VAR Center : Box;

      (* This variable defines the smallest possible box located at *)
      (* the center of the screen.                                  *)


   PROCEDURE Open;

      (* Open the screen.  This routine must be invoked prior to *)
      (* calling any GEM VDI or AES routines.  *)

 
   PROCEDURE Close;

      (* Close the screen and deactivate the workstation.  This routine *)
      (* should be called prior to termination of the main program.     *)


   PROCEDURE SetClippingRectangle ( ClipFlag  : ClipStatus;
                                    Rectangle : Box );

      (* Set the clipping rectangle to the boundaries specified *)
      (* by Rectangle.                                          *)


   PROCEDURE ContainsPoint ( Region : Box;
                             Point  : PixelCoordinate ) : BOOLEAN;

      (* Return TRUE if the region encloses the point, or FALSE *)
      (* otherwise.                                             *)


   PROCEDURE ContainsRectangle ( Region    : Box;
                                 Rectangle : Box ) : BOOLEAN;

      (* Return TRUE if the region encloses the rectangle, or FALSE *)
      (* otherwise.                                                 *)


   PROCEDURE Intersection ( Region1     : Box;
                            Region2     : Box;
                            VAR Overlap : Box ) : BOOLEAN;

      (* Calculate the intersection of the two regions.  If the two   *)
      (* regions intersect, the overlapping region is placed in       *)
      (* Overlap and TRUE is returned.  Otherwise, FALSE is returned. *)


END Screen.

